package com.vaadin.thomas.contenttool.demo;

import com.vaadin.Application;
import com.vaadin.terminal.gwt.server.WebApplicationContext;
import com.vaadin.thomas.contenttool.ui.AdminMainLayout;
import com.vaadin.thomas.contenttool.ui.AdminMainLayout.LogoutListener;
import com.vaadin.ui.AbstractOrderedLayout;
import com.vaadin.ui.Window;

public class AdminApplication extends Application {

	private static final long serialVersionUID = -8110358903988821822L;

	private static String appURL;

	@Override
	public void init() {

		Window mainWindow = new Window("ContentTool");
		((AbstractOrderedLayout) mainWindow.getContent()).setSpacing(true);
		((AbstractOrderedLayout) mainWindow.getContent()).setSizeFull();
		setMainWindow(mainWindow);

		AdminMainLayout ml = new AdminMainLayout(new SimpleConfig(), this);
		ml.setLogoutListener(new LogoutListener() {

			@Override
			public void logout() {
				close();
			}
		});
		mainWindow.setContent(ml);

		if (appURL == null) {
			appURL = ((WebApplicationContext) getContext()).getHttpSession()
					.getServletContext().getContextPath();
		}

		setTheme("cttheme");
	}

	public static String getAppURL() {
		return appURL;
	}
}
